<template>
	<view>
		<view class="status_bar">
		    <!-- 这里是状态栏 -->
		</view>
		<uni-nav-bar fixed >
			<view style="width: 220px;" >
				<uni-title type="h2" title="申请详情" align="center"></uni-title>
			</view>
			<view  slot="left">
				<uni-icons type="left" size="25px" @click="goback()"></uni-icons>
			</view>
			<view  slot="right">
			</view>
		</uni-nav-bar> 
		<view v-if="getfinish" style="display: flex; flex-direction:column;width: 100%; justify-content: center;font-size: 14px;font-weight: 300;margin-top: 15px;">
			<view style="width: 90%; align-self: center;border-bottom: solid #e6e6e6 0.7px;border-top: solid #e6e6e6 0.7px;">
				<view style="font-size: 17px;font-weight: 500;margin-top: 15px;">操作时间</view>
				<view style="display: flex; flex-direction:row; justify-content:space-between;margin-top: 10px;">
					<view>申请时间</view>
					<view>{{gettime(apply.apply_time)}}</view>
				</view>
				<view style="display: flex; flex-direction:row; justify-content:space-between;margin-top: 5px;margin-bottom: 15px;">
					<view>审批时间</view>
					<view v-if="apply.is_pass!='0'">{{gettime(apply.approve_time)}}</view>
					<view v-if="apply.is_pass=='0'">未审批</view>
				</view>
			</view>
			<view style="width: 90%; align-self: center;border-bottom: solid #e6e6e6 0.7px;">
				<view style="font-size: 17px;font-weight: 500;margin-top: 15px;">申请导师</view>
				<view style="display: flex; flex-direction:row; justify-content:space-between;margin-top: 5px;margin-bottom: 15px;">
					<view>导师类型</view>
					<view>{{apply.type_name}}</view>
				</view>
			</view>
			<view style="width: 90%; align-self: center;border-bottom: solid #e6e6e6 0.7px;">
				<view style="font-size: 17px;font-weight: 500;margin-top: 15px;">审批状态</view>
				<view style="display: flex; flex-direction:row; justify-content:space-between;margin-top: 10px;margin-bottom: 15px;">
					<view>审批结果</view>
					<view v-if="apply.is_pass=='0'">待审批</view>
					<view v-if="apply.is_pass=='1'">通过</view>
					<view v-if="apply.is_pass=='2'">拒绝</view>
				</view>
			</view>
			<view style="width: 90%; align-self: center;border-bottom: solid #e6e6e6 0.7px;">
				<view style="font-size: 17px;font-weight: 500;margin-top: 15px;">审批意见</view>
				<view style="display: flex; flex-direction:row; justify-content:space-between;margin-top: 10px;">
					<view>通过理由</view>
					<view v-if="apply.is_pass!='0'">{{apply.apply_reason}}</view>
				</view>
				<view style="display: flex; flex-direction:row; justify-content:space-between;margin-top: 5px;margin-bottom: 15px;">
					<view>拒绝理由</view>
					<view v-if="apply.is_pass!='0'">{{apply.refuse_reason}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				httpurl: getApp().globalData.weburl, //app.vue中定义的全局变量，后端ip地址
				apply_id:'',
				getfinish:false,
				apply:{}
			}
		},
		computed:{
			gettime() {
			    return (time1) => {
					return time1.replaceAll('-','.')
			    }
			}
		},
		onLoad: function (option) {
		    this.apply_id = option.apply_id;
			console.log(this.apply_id);
			this.getApplyDetail();
		},
		onPullDownRefresh() {
			console.log('下拉刷新');
			this.getApplyDetail();
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 500);
		},
		methods: {
			goback(){
				console.log("返回")
				uni.navigateBack({
				    delta: 1,//新注释
				});
			},
			getApplyDetail(){
				var that=this;
				uni.request({
				    url: that.httpurl+'getApplyDetail/', //服务器地址+接口名
				    data: {
						apply_id:that.apply_id	
				    },
					method: 'POST',
				    header: { 
						'X-Requested-With': 'XMLHttpRequest',
						"Accept": "application/json",
						"Content-Type": "application/json; charset=UTF-8"
					},
					dataType: 'json',
				    success: (res) => {
						console.log("request success");
				        console.log(res.data);
						that.apply=res.data.apply;
						that.getfinish=true;	
				    },
					fail: (res) => {
						console.log("request fail");
				    },
				});
			}
		}
	}
</script>

<style>
	.status_bar {
	    height: var(--status-bar-height);
	    width: 100%;
		background-color: white;
	}
</style>
